package com.bbb.common.exception.handler;

import com.baomidou.mybatisplus.extension.api.R;
import com.bbb.common.Code;
import com.bbb.common.Result;
import com.bbb.common.exception.ServiceException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理 ServiceException 异常
     */
    @ExceptionHandler(ServiceException.class)
    public Result serviceExceptionHandler(ServiceException e) {
        e.printStackTrace();
        return new Result(Code.UN_LOGIN, "用户未登录");
    }
}
